package com.shxzz.shortlink.admin.controller;

import com.shxzz.shortlink.admin.common.convention.result.Result;
import com.shxzz.shortlink.admin.remote.LinkRemoteService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shxzz
 * @create 2023-12-29-15:56
 * @description 源地址信息控制层
 */
@RestController
@RequiredArgsConstructor
public class UrlInfoController {

    /**
     * 后续重构为 SpringCloud Feign 调用
     */
    LinkRemoteService shortLinkRemoteService = new LinkRemoteService() {
    };

    /**
     * 获取目标网址标题
     */
    @GetMapping("/api/short-link/admin/v1/title")
    public Result<String> getTargetUrlTitle(@RequestParam("url") String targetUrl) {
        return shortLinkRemoteService.getTargetUrlTitle(targetUrl);
    }
}
